FROM node:10.15 as node_build
MAINTAINER biebbwa@163.com
ADD server.tar.gz /app
COPY docker-entrypoint.sh /usr/local/bin
COPY wait-for-it.sh /usr/local/bin
RUN chmod +x /usr/local/bin/wait-for-it.sh && \
    chmod +x /usr/local/bin/docker-entrypoint.sh  && \
    cd /app/server-side && \
    npm config set registry http://registry.npm.taobao.org && \
    npm install -g pm2
#    && \
#    npm install -g forever

WORKDIR /app/server-side
ENTRYPOINT wait-for-it.sh mysql:3306 -s -t 0 -- docker-entrypoint.sh



#FROM node_build as dbserv
#WORKDIR /app/server-side
#CMD wait-for-it.sh mysql:3306 -s -t 0 -- pm2 start  dbserv.js -node-args="--max-old-space-size=1024" && tail -f   /app/server-side/logs/*.log
#
#FROM node_build as gate
#WORKDIR /app/server-side
#CMD wait-for-it.sh mysql:3306 -s -t 0 -- pm2 start  gate.js -node-args="--max-old-space-size=1024" && tail -f   /app/server-side/logs/*.log
#
#FROM node_build as game
#WORKDIR /app/server-side
#CMD wait-for-it.sh mysql:3306 -s -t 0 -- pm2 start  game.js -node-args="--max-old-space-size=4096" && tail -f   /app/server-side/logs/*.log
#
#FROM node_build as game2
#WORKDIR /app/server-side
#CMD wait-for-it.sh mysql:3306 -s -t 0 -- pm2 start  game2.js -node-args="--max-old-space-size=4096" && tail -f   /app/server-side/logs/*.log
#
#FROM node_build as game3
#WORKDIR /app/server-side
#CMD wait-for-it.sh mysql:3306 -s -t 0 -- pm2 start  game3.js -node-args="--max-old-space-size=4096" && tail -f   /app/server-side/logs/*.log
#
#FROM node_build as game4
#WORKDIR /app/server-side
#CMD wait-for-it.sh mysql:3306 -s -t 0 -- pm2 start  game4.js -node-args="--max-old-space-size=4096" && tail -f   /app/server-side/logs/*.log